#include "MeteManager.h"

class MeteManager;

bool MeteManager::init(){
	air = Air::create();
	this->addChild(air, 1, 1);
	visibleSize = Director::getInstance()->getVisibleSize();
	createMete();
	this->scheduleUpdate();
	air->setTouchLayer(this);
	return true;
}
Air* MeteManager::getAir(){
	return air;
}

void MeteManager::createMete(){
	//Meteorolite* mete = NULL;
	NormalMete* mete = NULL;
	for (size_t i = 0; i < 10; i++){
		mete = NormalMete::create();
		mete->bindMete(Sprite::create("star1.png"));
		mete->getMete()->setCenter(Point(visibleSize.width / 2, visibleSize.height / 2));
		mete->getMete()->getSprite()->setScale(0.2);
		mete->getMete()->setPst(Point(800 * sin(i), 300 * sin(i)));
		mete->getMete()->setVel(Point(-0.02, 0.02));
		air->checkCrash(mete->getMete()->getSprite());
		this->addChild(mete->getMete());
		metesArray.pushBack(mete);

	}
}

void MeteManager::update(float dt){
	for (auto mete : metesArray)
	{
		mete->getMete()->setResi(air->getContactAirParticleNum(mete->getMete()->getSprite()));
		mete->getMete()->move();
	}
}
/*******************************************************/